package de.backtomedieval.scenarios;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import de.backtomedieval.R;
import de.backtomedieval.activities.gamemenu.FightScreen;
import de.backtomedieval.game.Fight;
import de.backtomedieval.main.Game;
import de.backtomedieval.units.UnitSet;

public abstract class AbstractAttackMonsterScenario extends AbstractScenario {

	private UnitSet enemy = new UnitSet(null);
	
	public UnitSet getEnemy() {
		return enemy;
	}

	public void setEnemy(UnitSet enemy) {
		this.enemy = enemy;
	}

	@Override
	public void winScenario() {
		if (Game.getGame().getRoundnr()<this.getState() || this.getState()<1) {
			// We need an Editor object to make preference changes.
			// All objects are from android.context.Context
			SharedPreferences settings = Game.getSharedPreferences(Game.PREFS_NAME, 0);
			SharedPreferences.Editor editor = settings.edit();
			editor.putInt("scenario"+getID()+"won", (int) Game.getGame().getRoundnr());
			// Commit the edits!
			editor.commit();
		}
	}
	
	@Override
	public boolean addStartFight() {
		return true;
	}
	
	public void onStartFight() {
		UnitSet enemy = this.enemy;
		UnitSet player = Game.getGame().getcCity().getUnits();
		Fight fight = new Fight(player,enemy,Fight.PLAYER_ATTACKS,null);
		fight.setFinalFight(true);
		fight.start();
	}
	
	
	@Override
	public String getStateString() {
		String[] diff = Game.getStringArray(R.array.difficulty);
		if (getState() == -2) {
			return Game.getString(R.string.locked);
		} else if (getState() >= 0) {
			return Game.getString(R.string.completeafter) +" " + getState() + " " + Game.getString(R.string.rounds);
		} else if (getState() == -1) {
			return Game.getString(R.string.notcomplete);
		} else {
			return "";
		}
	}
	
	@Override
	public boolean checkScenarioGameTimeout(long round) {
		return false;
	}

	@Override
	public boolean checkWinConditions(Game g) {
		return false;
	}
	
	
}
